<?php
/**
 * Created by PhpStorm.
 * User: hotpot
 * Date: 2018/4/8
 * Time: 0:12
 */

namespace Admin\Controller;


use Common\Controller\AdminBaseController;

class ZykindController extends AdminBaseController
{
// 定义数据
    private $db;

    public function __construct(){
        parent::__construct();
        $this->db=D('Zykind');
    }

    // 种类列表
    public function index(){
        $data=$this->db->getDataByState(0,'all');
        $this->assign('data',$data);
        $this->display();
    }

    // 添加种类
    public function add(){
        if(IS_POST){
            if($this->db->addData()){
                $this->success('种类添加成功',U('Admin/Zykind/index'));
            }else{
                $this->error($this->db->getError());
            }
        }else{
            $this->display();
        }

    }

    // 修改
    public function edit(){
        if(IS_POST){
            if($this->db->editData()){
                $this->success('修改成功',U('Admin/Zykind/index'));
            }else{
                $this->error($this->db->getError());
            }
        }else{
            $kind_id=I('get.kind_id');
            $data=$this->db->getDataByLid($kind_id);
            $this->assign('data',$data);
            $this->display();
        }
    }
}